package com.lwj.constant;

import java.util.*;

public enum DepartmentType {
    ONE(1,"全国总部"),
    TOW(2,"区域部门","临时区域部门"),
    THREE(3,"省级部门","临时省级部门"),
    FOUR(4,"市级部门","临时市级部门"),
    FIVE(5,"县级部门","临时县级部门");
    private final Integer level;
    private final String[] types;
    private static Map<Integer, List<String>> levelMap=new HashMap();
    private static Map<String,Integer> typeMap=new HashMap();


    static {
        DepartmentType[] values = DepartmentType.values();
        for (int i = 0; i < values.length; i++) {
            DepartmentType entity = values[i];
            String[] types = entity.types;
            Integer integer = entity.level;
            levelMap.put(integer,new ArrayList<>(Arrays.asList(types)));
            for (int j = 0; j < types.length; j++) {
                typeMap.put(types[j],integer);
            }
        }
    }
    DepartmentType(Integer level, String...types) {
        this.level = level;
        this.types = types;
    }
    public static Integer level(String type){
        return typeMap.get(type);
    }

    public Integer getLevel() {
        return level;
    }

    public String[] getTypes() {
        return types;
    }
}
